package beans;

import java.util.ArrayList;

public class CharBean {
	

	private Integer id = 0;
	private String name = "";
	private Integer gewandheit = 0;
	private Integer körperkraft = 0;
	private Integer intuition = 0;
	private Integer fingerfertigkeit = 0;
	private Integer mut = 0;
	private Integer klugheit = 0;
	private Integer konstitution = 0;
	private Integer charisma = 0;
	private Integer attacke = 0;
	private Integer parade = 0;
	private ArrayList<TawBean> probenList = new ArrayList<TawBean>();

	public CharBean(Integer id, String name, int mu, int kl, int in, int ch,
					int ff, int ge, int ko, int kk, int attacke, int parade) {

		this.id = id;
		this.name = name;
		this.gewandheit = ge;
		this.körperkraft = kk;
		this.intuition = in;
		this.fingerfertigkeit = ff;
		this.mut = mu;
		this.klugheit = kl;
		this.konstitution = ko;
		this.charisma = ch;
		this.attacke = attacke;
		this.parade = parade;
	}

	public void addToProbenList(Integer id, Integer taw) {

		synchronized (probenList) {
			TawBean tawBean = new TawBean(id, taw);
			probenList.add(tawBean);
		}
	}

	public void clearProbenList() {

		synchronized (probenList) {
			probenList.clear();
		}
	}

	public Integer getAttacke() {

		return attacke;
	}

	public Integer getAttributByName(String string) {

		if (string.equals("FF")) {
			return fingerfertigkeit;
		} else if (string.equals("GE")) {
			return gewandheit;
		} else if (string.equals("KO")) {
			return konstitution;
		} else if (string.equals("KK")) {
			return körperkraft;
		} else if (string.equals("IN")) {
			return intuition;
		} else if (string.equals("AT")) {
			return attacke;
		} else if (string.equals("PA")) {
			return parade;
		} else if (string.equals("KL")) {
			return klugheit;
		} else if (string.equals("MU")) {
			return mut;
		} else if (string.equals("CH")) {
			return charisma;
		}
		System.out.println("hier läuft was falsch!");
		return 0;
	}

	public Integer getCH() {

		return charisma;
	}

	public Integer getCharId() {

		return id;
	}

	public Integer getFF() {

		return fingerfertigkeit;
	}

	public Integer getGE() {

		return gewandheit;
	}

	public Integer getIN() {

		return intuition;
	}

	public Integer getKK() {

		return körperkraft;
	}

	public Integer getKL() {

		return klugheit;
	}

	public Integer getKO() {

		return konstitution;
	}

	public Integer getMU() {

		return mut;
	}

	public String getName() {

		return name;
	}

	public Integer getParade() {

		return parade;
	}

	public ArrayList<TawBean> getProbenList() {

		return probenList;
	}

	public int getTawById(Integer key) {

		synchronized (probenList) {
			for (TawBean probe : probenList) {
				if (probe.getProbenId() == key) {
					return probe.getTaw();
				}
			}
		}
		return 0;
	}

	public void update(Integer id, String name, int mu, int kl, int in, int ch,
				int ff, int ge, int ko, int kk, int attacke, int parade) {

		this.id = id;
		this.name = name;
		this.gewandheit = ge;
		this.körperkraft = kk;
		this.intuition = in;
		this.fingerfertigkeit = ff;
		this.mut = mu;
		this.klugheit = kl;
		this.konstitution = ko;
		this.charisma = ch;
		this.attacke = attacke;
		this.parade = parade;
	}

	public void updateProbe(Integer key, Integer taw) {

		synchronized (probenList) {
			for (TawBean probe : probenList) {
				if (probe.getProbenId() == key) {
					probenList.remove(probe);
				}
			}
			TawBean tawBean = new TawBean(key, taw);
			probenList.add(tawBean);
		}
	}
}
